const INFO_KEY = "hm_shopping_info";

// 获取个人信息
export const getInfo = () => {
  const result = localStorage.getItem(INFO_KEY);
  return result ? JSON.parse(result) : { token: "", userId: "" };
};

// 设置个人信息
export const setInfo = (info) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(info));
};

// 移除个人信息
export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY);
};

// 列表历史数据
const HISTORY_KEY = "hm_history_key";
export const getHistoryList = () => {
  const result = localStorage.getItem(HISTORY_KEY);
  return result ? JSON.parse(result) : [];
};

export const setHistoryList = (arr) => {
  localStorage.setItem(HISTORY_KEY, JSON.stringify(arr));
};
